package ex.ex2;

import org.apache.storm.Config;
import org.apache.storm.thrift.TException;
import org.apache.storm.utils.DRPCClient;
import org.apache.storm.utils.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Map;

public class PublicSentimentDRPCClient {
    private static final Logger logger = LoggerFactory.getLogger(PublicSentimentDRPCTopology.class);

    public static void main(String[] args) throws TException {
        Config config = new Config();
        Map<String, Object> defaultConfig = Utils.readDefaultConfig();
        config.putAll(defaultConfig);

        DRPCClient drpcClient = new DRPCClient(config, "liu", 3772);

        String[] urls = new String[]{
                "12345 投诉", "新冠疫情", "海边游玩"
        };

        for (String url : urls) {
            String result = drpcClient.execute("infoResearch",url); // 需要与 ReachTopology 153 function 相同
            logger.info(result);
        }

    }
}
